<script>

jQuery(document).ready(function($) {
	
	/*		
	$(".import_service").click(function(event) {
				var a = $(this).attr('id');
				$( "#id_service" ).val( a );
				var url = "services/import/" + a;
				//alert(url);
				$.ajax({
					url:url,
					data:{id:a},
					success: function(output) {
							$( "#result" ).html( output );
							//alert(output);
							},
					error: function (request, status, error) {
						alert("Error");},
				 });
				$("#dialog-importservice").dialog({
					resizable: false,
					title: "Nhập kho",
					height: 'auto',
					width: '700',
					modal: true					
				});	
				
				 
				//alert(a);
			});
			
			$(".add_service").click(function(event) {
				//var id = "."+$(this).attr('id');		
				$("#dialog-addservice").dialog({
					resizable: false,
					title: "Thêm dịch vụ",
					height: 'auto',
					width: 'auto',
					modal: true
				});
			});	
			*/
			 $( "#dialogModal" ).dialog({
				height: 'auto',
				width: 'auto',
				autoOpen: false,
				show: {
					effect: "blind",
					duration: 500
					
					},
				hide: {
					effect: "blind",
					duration: 500
					},
				modal: true,
				
				});
    //respond to click event on anything with 'overlay' class
			$(".overlay").click(function(event){
				event.preventDefault();
				$('#contentWrap').load($(this).attr("href"));  //load content from href of link
				$('#dialogModal').dialog('option', 'title', $(this).attr("title"));  //make dialog title that of link
				$('#dialogModal').dialog('open');  //open the dialog
				});
				
});
Number.prototype.format = function(n, x) {
	var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
	return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
};
</script>
<div id="dialogModal">
     <!-- the external content is loaded inside this tag -->
     <div id="contentWrap"></div>
</div>
<div class="cate-infor">
	<div class="block-title">
		<h3>Danh sách dịch vụ</h3>
		<?php echo $this->Html->link(__('Thêm dịch vụ', true), array("controller"=>"services", "action"=>"add"), array("class"=>"overlay add_service", "title"=>"Thêm dịch vụ"));?>

		
	</div>
	<div class="block-content">
		<form action="#">
			<label>Lọc theo</label>&nbsp; <input type="text" style="width: 90px;"> &nbsp; <input type="text" style="width: 90px;">&nbsp; - &nbsp;
			<input type="text" style="width: 90px; margin-right: 10px;">
			<select style="padding: 2px 10px; border: 1px solid #C0C0C0;">
				<option value="">Mục chi</option>
				<option value="">Đồ uống</option>
				<option value="">Đồ ăn</option>
			</select> &nbsp;
			<input type="submit" value="">
		</form>
		<style>
		.dv{
		font: 12px sans-serif;
		}
		
.row {
    margin-bottom: 8px;
    overflow: hidden;
}
.row input,.row select {
    border: 1px solid #c0c0c0;
    padding: 3px;
	}
.row label {
    float: left;
    width: 100px;
}
.row textarea {
    border: 1px solid #c0c0c0;
    box-sizing: border-box;
    max-width: 256px;
    min-height: 70px;
    padding: 4px;
    width: 256px;
}
.btn-dialog {
    border-top: 1px solid #c0c0c0;
    margin-top: 10px;
    padding: 10px 2px 0 0;
    text-align: right;
}
.btn-dialog input {
    border: 1px solid #c0c0c0;
    cursor: pointer;
    padding: 3px 10px;
}
.btn-dialog input[type="button"] {
    float: right;
    margin-left: 10px;
}

		</style>
		<table cellspacing="0" cellpadding="0" width="100%" class="dv">
			<tr>
				<th style="text-align: center; width: 4%;">STT</th>
				<th style="text-align: center; width: 23%;">Tên dịch vụ</th>
				<th style="text-align: center; width: 11%;">Đơn vị</th>
				<th style="text-align: center; width: 10%;">Đã nhập</th>
				<th style="text-align: center; width: 11%;">Tồn kho</th>
				<th style="text-align: center; width: 10%;">Đã bán</th>
				<th style="text-align: center; width: 11%;">Giá bán</th>
				<th style="text-align: center; width: 11%;">Tổng cộng</th>
				<th style="text-align: center; width: 9%;">Công cụ</th>
			</tr>
			<?php foreach($cate as $k=>$v){?>
			<tr>
				<td colspan="9" style="text-align: left; padding-left: 10px; box-sizing: border-box; font-weight: bold;"><img src="<?php echo $this->webroot;?>img/icons/O2b.png" alt="O2b" >&nbsp; <?php echo $v;?></td>
			</tr>
			
			<?php $lists = $this->requestAction('/services/listservice/'.$k); $i=0;?>
			<?php foreach( $lists as $service){?>
			<?php $count_service  = $this->requestAction('/services/countservice/'.$service['Service']['id']);
			
			//debug( $count_service );
			?>
			<tr>
				<td style="text-align: center"><?php echo $i;?></td>
				<td style="text-align: left; padding-left: 6px; box-sizing: border-box;"><?php echo $service['Service']['name'];?></td>
				<td style="text-align: center;  box-sizing: border-box;"><?php echo $service['Service']['unit'];?></td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box;"><?php echo $count_service;?> &nbsp; 
				<?php echo $this->Html->link($this->Html->image("icons/add-icon.png", array("alt" => "Brownies",'width'=>12)),array('controller' => 'importServices','action' => 'add','id' => $service['Service']['id'],'slug' => Inflector::slug($service['Service']['name'],'-'),'comments' => false),array('escape' => false,"class"=>"overlay", "title"=>"Nhập kho ".$service['Service']['name']));?></td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box;">Chưa tính</td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box;">Chưa tính
				</td>
				
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box;">
				<script>
				var i = <?php echo $service['Service']['price']?>;
				document.write( i.format(2) + ' VNĐ');
				</script></td>
				<td style="text-align: right; padding-right: 6px;">Chưa tính</td>
				<td style="text-align: center"><?php echo $this->Html->link(__('Sửa', true), array("controller"=>"services", "action"=>"edit",'id' => $service['Service']['id'],'slug' => Inflector::slug($service['Service']['name'],'-')), array("class"=>"overlay", "title"=>"Sửa dịch vụ"));?> | <?php echo $this->Html->link(__('Xóa', true), array('controller'=>'services','action' => 'delete','id' => $service['Service']['id'],'slug' => Inflector::slug($service['Service']['name'],'-')), null, sprintf(__('Bạn có chắc muốn xóa mục này không ?', true), $service['Service']['id'])); ?></td>
			</tr>
			<?php $i++;?>
			<?php } }?>
			
			<tr>
				<td style=""></td>
				<td style="text-align: center"></td>
				<td></td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box; font-weight: bold;">35</td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box; font-weight: bold;">10,72</td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box; font-weight: bold;">32</td>
				<td></td>
				<td style="text-align: right; padding-right: 6px; box-sizing: border-box; font-weight: bold;">111111</td>
				<td></td>
			</tr>
		</table>
		<div class="page">
			<ul>
				<li><a href="">Prev</a></li>
				<li><a href="">1</a></li>
				<li><a href="">Next</a></li>
			</ul>
		</div>
		<ul id="hd">
			<li style="font-weight: bold;">*** Hướng dẫn :</li>
			<li>- &nbsp;Mục [Đã nhập] , [Đã bán] , [Tổng cộng] thống kê theo thời gian đã chọn
			</li>
			<li>- &nbsp;Mục [Tồn kho] là tổng số tồn cho đến thời điểm hiện tại. Để nhập/xuất kho vui lòng bấm vào dấu <img src="<?php echo $this->webroot;?>img/icons/add-icon.png" width="12" alt="cộng">
			</li>
			<li>- &nbsp;Để mở chức năng Xuất/Nhập kho vui lòng chọn sửa. Đánh vào dấu &nbsp; <input type="checkbox" value="" checked>&nbsp; Cho phép nhập xuất kho</li>
		</ul>
	</div>
</div>
<?php echo $this->Html->script('jquery.maskMoney');?>

 
 